﻿using System;
using System.Linq;
using System.Reflection;

namespace Fabrication.ValueProviders
{
    internal sealed class NullableProvider : IValueProvider
    {
        private Type actualType;

        public void Initialize(PropertyInfo property)
        {
            actualType = property.PropertyType.GetGenericArguments().Single();
        }

        object IValueProvider.GetValue(object item)
        {
            return Activator.CreateInstance(actualType);
        }
    }
}